SCANNING Function
Syntax
Arguments
- tablename
A child table from a set.
Description
Returns TRUE if the supplied child table is being fetched through.
Discussion
SCANNING() returns .T. (TRUE) if the current composite record buffer includes data from Table_Name ; otherwise, it returns .F. (FALSE). This function is useful for determining whether a parent record has been linked to an existing child record. If the SCANNING() function applied to the child table returns .F. (FALSE), there is no child record related to the current parent record. For example, suppose you have a VENDOR table linked one-to-many to a PRODUCTS table. Each vendor should be related to at least one product; when a Vendor record is missing a related PRODUCTS record, you use the SCANNING() function. The expression, .NOT. SCANNING("PRODUCT"), returns TRUE (.T.) for a vendor that has no products. You can use the SCANNING() function when working with sets that have multiple one-to-many links at the same level.
Example
Assume the following two tables, INVOICE and CUSTOMER, are linked one-to-one:
- CUSTOMER
- >
- CUST_ID
LAST_NAME
- C001
Gorby
- C002
Peabody
- C003
Smith
- INVOICE
- >
- INV_NO
- CUST_ID TOTAL
- I100
C001 10.00
- I101
C003 25.50
- I102
C001 100.75
- I103
C004 32.50
- I104
C002 110.25
- I105
C005 98.35
To determine if a there is a matching customer for a particular invoice record, use the expression:
scanning("CUSTOMER") -> .F. (FALSE) for invoice records I103 and I105
See Also